package com.yaozheng.vocationaltraining.view;

import net.sf.json.JSONObject;

import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

import com.yaozheng.vocationaltraining.R;
import com.yaozheng.vocationaltraining.iview.IVideoCoursewareOperatingView;
import com.yaozheng.vocationaltraining.iview.IVideoCoursewareView;
import com.yaozheng.vocationaltraining.utils.Constants;
import com.yaozheng.vocationaltraining.utils.TypeUtils;

import android.content.Context;
import android.content.Intent;
import android.text.Html;
import android.util.AttributeSet;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

@EViewGroup(R.layout.view_video_courseware_detail)
public class VideoCoursewareDetailView extends LinearLayout {
    @ViewById
    TextView coursewareLearnCountText, coursewareDownloadCountText,
            coursewareLecturerText, coursewareFieldText, coursewareFormatText,
            coursewareClassText, coursewareIntegralText;
    @ViewById
    Button coursewareOperatingBut;

    IVideoCoursewareOperatingView iVideoCoursewareView;


    public VideoCoursewareDetailView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public VideoCoursewareDetailView(Context context) {
        super(context);
    }

    public void init(IVideoCoursewareOperatingView iVideoCoursewareView) {
        this.iVideoCoursewareView = iVideoCoursewareView;
    }

    public Button getCoursewareOperatingBut() {
        return coursewareOperatingBut;
    }

    /**
     * 设置课件详情文字
     */
    public void setVideoCoursewareDetailText(JSONObject courserJsonObject) {

        coursewareLearnCountText.setText(String.valueOf(
                TypeUtils.getJsonInteger(courserJsonObject,
                        "period", 0)));
        coursewareDownloadCountText.setText(String.valueOf(
                TypeUtils.getJsonInteger(courserJsonObject,
                        "award", 0)));

//        coursewareLecturerText.setText(getContext().getString(
//                R.string.lecturerStr,
//                TypeUtils.getJsonString(courserJsonObject, "lecturer", "")));
//
//        coursewareFieldText.setText(getContext().getString(
//                R.string.curriculumAreasStr,
//                TypeUtils.getJsonString(courserJsonObject, "domain", "")));
//
//        coursewareFormatText.setText(getContext().getString(
//                R.string.courseFormatStr,
//                TypeUtils.getJsonString(courserJsonObject, "format", "")));
//
//        coursewareClassText.setText(getContext().getString(
//                R.string.classTimeStr,
//                TypeUtils.getJsonInteger(courserJsonObject, "period") + "课时"));
//
//        coursewareIntegralText.setText(getContext().getString(
//                R.string.coursePointsStr,
//                TypeUtils.getJsonInteger(courserJsonObject, "award", 0) + "分"));
    }


    /**
     * 下载点击
     */
    @Click(R.id.coursewareOperatingBut)
    public void coursewareOperatingButClick() {
        if (iVideoCoursewareView != null) {
            iVideoCoursewareView.coursewareOperatingButClick();
        }
    }

}
